package com.bsoft.AQS;

import org.omg.PortableInterceptor.LOCATION_FORWARD;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
 * @program: demo
 * @description:
 * @author: hdh
 * @create: 2022:04:02 13:50
 */
//不需要锁块   正常 无锁块

public class LockSupper2 {
    public static void main(String[] args) throws InterruptedException {

      Thread a=   new Thread(()->{
//          try {
//              TimeUnit.SECONDS.sleep(3);
//          } catch (InterruptedException e) {
//              e.printStackTrace();
//          }
          System.out.println(Thread.currentThread().getName()+"\t"+"-----com in"+System.currentTimeMillis());
         // LockSupport.park();//被阻塞......等待通知等待放行，但是需要许可证
          LockSupport.park();
          System.out.println(Thread.currentThread().getName()+"\t"+"------被唤醒"+System.currentTimeMillis());
        },"a");
      a.start();


        Thread b=   new Thread(()->{

           // LockSupport.unpark(a);;//被阻塞......等待通知等待放行，但是需要许可证
            LockSupport.unpark(a);
            System.out.println(Thread.currentThread().getName()+"\t"+"------通知了");
        },"b");
        b.start();

    }
}
